package com.android.xunxian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.xunxian.entry.BoxMxListBean;
import com.oa.android.R;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by 设备 on 2016/7/3.
 */
public class BoxMxAdpter extends BaseAdapter {

    private Context context;
    private List<BoxMxListBean> deviceList;

    public BoxMxAdpter(Context context, List<BoxMxListBean> deviceList) {
        this.context = context;
        this.deviceList = deviceList;
    }


    @Override
    public int getCount() {
        return deviceList.size();
    }

    @Override
    public Object getItem(int position) {
        return deviceList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;

        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.box_mx_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

       try {
         viewHolder.bxbh.setText(""+deviceList.get(position).getBOXID());
         viewHolder.sbbh.setText(""+deviceList.get(position).getSBBH());
        viewHolder.sbgg.setText(""+deviceList.get(position).getSBGG());
           viewHolder.qymc.setText(""+deviceList.get(position).getPARTNAME());
           viewHolder.khxm.setText(""+deviceList.get(position).getUSERNAME());
           viewHolder.khbh.setText(""+deviceList.get(position).getUSERID());
           viewHolder.ysxq.setText(""+deviceList.get(position).getPRIMEMO());
           viewHolder.gszt.setText(""+deviceList.get(position).getSSBZT());
           viewHolder.lxdh.setText(""+deviceList.get(position).getLXDH());
           viewHolder.xxdz.setText(""+deviceList.get(position).getXXDZ());
       }catch (Exception e){

       }

        return convertView;
    }



    class ViewHolder {
        @InjectView(R.id.bxbh)
        TextView bxbh;
        @InjectView(R.id.sbbh)
        TextView sbbh;
        @InjectView(R.id.sbgg)
        TextView sbgg;
        @InjectView(R.id.qymc)
        TextView qymc;
        @InjectView(R.id.khxm)
        TextView khxm;
        @InjectView(R.id.khbh)
        TextView khbh;
        @InjectView(R.id.ysxq)
        TextView ysxq;
        @InjectView(R.id.gszt)
        TextView gszt;
        @InjectView(R.id.lxdh)
        TextView lxdh;
        @InjectView(R.id.xxdz)
        TextView xxdz;

        ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
